package com.tony.mindhr.service;

import com.tony.mindhr.mapper.DepartmentMapper;
import com.tony.mindhr.model.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Title: DepartmentService
 * @Auther: 皮蛋布丁
 * @Date: 2021/06/05/16:26
 * @Description:
 */
@Service
public class DepartmentService {

    @Autowired
    DepartmentMapper departmentMapper;

    /**
    * @Description: getAllDepartments 获取所有部门
    * @Param: []
    * @return: java.util.List<com.tony.mindhr.model.Department>
    * @Author: 皮蛋布丁
    * @Date: 2021/6/5 16:29
    */
    public List<Department> getAllDepartments() {
        return departmentMapper.getAllDepartmentsByParentId(-1);
    }

    /**
    * @Description: addDep 添加部门
    * @Param: [dep]
    * @return: void
    * @Author: 皮蛋布丁
    * @Date: 2021/6/6 16:43
    */
    public void addDep(Department dep) {
        dep.setEnabled(true);
        departmentMapper.addDep(dep);
    }

    /**
    * @Description: deleteDepById 根据id删除部门
    * @Param: [dep]
    * @return: void
    * @Author: 皮蛋布丁
    * @Date: 2021/6/6 21:22
    */
    public void deleteDepById(Department dep) {
        departmentMapper.deleteDepById(dep);
    }

    /**
    * @Description: getAllDepartmentsWithOutChildren 获取部门列表
    * @Param: []
    * @return: java.util.List<com.tony.mindhr.model.Department>
    * @Author: 皮蛋布丁
    * @Date: 2021/6/19 20:37
    */
    public List<Department> getAllDepartmentsWithOutChildren() {
        return departmentMapper.getAllDepartmentsWithOutChildren();
    }
}
